
package beans;

import database.DBController;
import domain.User;
import java.io.Serializable;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class registerBean implements Serializable {
    DBController dbc = new DBController();

    public registerBean() throws SQLException{

    }
     protected User u = new User();


    public User getU() {
        return u;
    }

    public void setU(User u) {
        this.u = u;
    }

    public String saveNewUser() throws Exception
    {
        System.out.printf("u.getUserNick():%s \n",u.getUserNick());
        
        dbc = new DBController();
        int user_local_id =0;
        dbc.increaseUserCounter();
        try {
            //dbc.increaseWriterCounter();
            user_local_id=dbc.getUserCounter();
            System.out.printf("user_local_id satir 38: %d \n",user_local_id);
        } catch (Exception ex) 
        {
            System.err.println("...........satir 41 hata");
            Logger.getLogger(registerBean.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        
        u.setId(user_local_id);
        dbc.saveUser(this.u);
        return "true";
    }

    
    /*public boolean checkUserName(String str){
        
        if(str.length() == 0){ return false; }
        else{ return true; 
        
        new Message("nameinput","hatalı") {}}
        
    }*/
}
